package org.orz.story.works.biz.clubhouse.web.frontend;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.orz.cloud.common.result.ResultDTO;
import org.orz.story.works.biz.clubhouse.model.req.AddDiaryReq;
import org.orz.story.works.biz.clubhouse.model.req.DeleteDiaryReq;
import org.orz.story.works.biz.clubhouse.model.req.UpdateDiaryReq;
import org.orz.story.works.biz.clubhouse.model.resp.ListWorksDiaryResp;
import org.orz.story.works.biz.clubhouse.service.WorksDiaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("clubHouse/worksDiary")
@Api(tags = "日记相关接口")
public class WorksDiaryController {
    @Autowired
    private WorksDiaryService worksDiaryService;

    @PostMapping("addDiary")
    @ApiOperation("新增日记")
    public ResultDTO<Boolean> addDiary(@RequestBody AddDiaryReq req){
        worksDiaryService.addDiary(req);
        return ResultDTO.success();
    }

    @PostMapping("updateDiary")
    @ApiOperation("修改日记")
    public ResultDTO<Boolean> updateDiary(@RequestBody UpdateDiaryReq req){
        worksDiaryService.updateDiary(req);
        return ResultDTO.success();
    }

    @PostMapping("deleteDiary")
    @ApiOperation("删除日记")
    public ResultDTO<Boolean> deleteDiary(@RequestBody DeleteDiaryReq req){
        worksDiaryService.deleteDiary(req);
        return ResultDTO.success();
    }

    @ApiOperation("查询日记列表")
    @PostMapping("listWorksDiary")
    public ResultDTO<List<ListWorksDiaryResp>> listWorksDiary(){
        return ResultDTO.success(worksDiaryService.listWorksDiary());
    }

}
